package com.wangsong.system.controller;


import com.wangsong.common.model.CodeEnum;
import com.wangsong.common.model.Result;
import com.wangsong.system.entity.Resources;
import com.wangsong.system.service.IResourcesService;


import org.springframework.beans.factory.annotation.Autowired;

import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.security.core.context.SecurityContextHolder;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;

import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.bind.annotation.RestController;
import com.wangsong.common.controller.BaseController;

import java.util.List;

/**
 * <p>
 *  前端控制器
 * </p>
 *
 * @author jobob
 * @since 2021-09-19
 */
@RestController
@RequestMapping("/system/resources")
public class ResourcesController extends BaseController {
    @Autowired
    private IResourcesService resourcesService;

    @PreAuthorize("hasAuthority('/system/resources/add')")
    @RequestMapping(value = "/add")
    public Result add(@RequestBody Resources resources) {
        resourcesService.insertResources(resources);
        return  Result.success();
    }


    @PreAuthorize("hasAuthority('/system/resources/delete')")
    @RequestMapping(value = "/delete")
    public Result delete(Long id) {
        resourcesService.deleteResources(id);
        return Result.success();
    }

    @PreAuthorize("hasAuthority('/system/resources/update')")
    @RequestMapping(value = "/update")
    public Result update(@RequestBody Resources resources) {
        resourcesService.updateResources(resources);
        return Result.success();

    }

    @PreAuthorize("hasAuthority('/system/resources/list')")
    @RequestMapping(value = "/list")
    public Result list() {
        return Result.success(resourcesService.findResources());
    }

    @RequestMapping(value = "/selectByPrimaryKey")
    public Result selectByPrimaryKey(Long id) {
        return Result.success(resourcesService.selectByPrimaryKey(id));
    }
}
